using System.Collections;
using System.Collections.Generic;
using UnityEngine; 
using Unity;
static class MathUtils
{
    static public float Tanh(float x)
    {
        float res = (Mathf.Exp(x)-Mathf.Exp(-x))/(Mathf.Exp(x)+Mathf.Exp(-x));
        return float.IsNaN(res)?1.0f:res;
    } 

    static public float NormalDisSample(float mean, float std)
    {
        if(std == 0)
            return mean;
        float rand1 = Random.Range(float.Epsilon, 1.0f);
        float rand2 = Random.Range(float.Epsilon, 1.0f);
        float res;
        if(std < 0)
            Debug.LogError("[Normal Distribution Sampler]: The std value should be positive.");
        res = std * Mathf.Sqrt(-2*Mathf.Log(rand1)) * Mathf.Cos(2*Mathf.PI*rand2) + mean;
        return res;
    }
}

